package com.study.lihan.proxy.jdk;

import com.study.lihan.proxy.UserInterface;
import com.study.lihan.proxy.UserService;

import java.lang.reflect.Proxy;

/**
 * @Author: lihan
 * @Date : 2021/12/31- 12
 * @DESCRIPTION: com.study.lihan.proxy.jdk
 * @version: 1.0
 */
public class TestJdk {
    public static void main(String[] args) {
        System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles","true");
        UserService userService = new UserService();
        MyInvocationHandler invocationHandler = new MyInvocationHandler(userService);
        UserInterface instance =(UserInterface) Proxy.newProxyInstance(UserService.class.getClassLoader(),
                                                                        new Class[]{UserInterface.class},
                                                                            invocationHandler);
        instance.test();
    }
}
